using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableTalentAdvencedDao:DaoBase<TableTalentAdvenced>
    {
        public override void AddPrimaryIndex(TableTalentAdvenced model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableTalentAdvenced.txt";
        }

        protected override TableTalentAdvenced ParseRowData(string[] rowData)
        {
            TableTalentAdvenced data = new TableTalentAdvenced();
			data.id = rowData [0];
			data.warId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.trunck = 0;
            }
            else
            {
                data.trunck = int.Parse(rowData[2]);
            }
			data.talentLevel = rowData [3];
			data.parent = rowData [4];
			data.parent2 = rowData [5];
			data.talentId = rowData [6];

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.levelLimit = 0;
            }
            else
            {
                data.levelLimit = int.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.attGrow = 0;
            }
            else
            {
                data.attGrow = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.hpGrow = 0;
            }
            else
            {
                data.hpGrow = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.pdefGrow = 0;
            }
            else
            {
                data.pdefGrow = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.mdefGrow = 0;
            }
            else
            {
                data.mdefGrow = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.attConstAdd = 0;
            }
            else
            {
                data.attConstAdd = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.hpConstAdd = 0;
            }
            else
            {
                data.hpConstAdd = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.pdefConstAdd = 0;
            }
            else
            {
                data.pdefConstAdd = double.Parse(rowData[14]);
            }

            if (string.IsNullOrEmpty(rowData[15]))
            {
                data.mdefConstAdd = 0;
            }
            else
            {
                data.mdefConstAdd = double.Parse(rowData[15]);
            }
			data.cost = rowData [16];
			data.icon = rowData [17];

            return data;
        }


        public override void AddOneIndex(TableTalentAdvenced model)
        {
            if (!cacheOneIndex.ContainsKey(model.warId.ToString()))
            {
                cacheOneIndex[model.warId.ToString()] = new List<TableTalentAdvenced>();
            }
            cacheOneIndex[model.warId.ToString()].Add(model);
        }
    

    }

}
